package cn.com.bluemoon.daps.sync.core.sync.executor;

import cn.com.bluemoon.daps.common.exception.DapThrowException;
import cn.com.bluemoon.daps.sync.core.sync.GlobalConfig;

/**
 * @author Jarod.Kong
 * @date 2021-06-05 11:16
 **/
public class SqlExecutors {
    public static SqlExecutor jdbc(GlobalConfig globalConfig) {
        return new JdbcSqlExecutor(globalConfig);
    }

    public static SqlExecutor pt(GlobalConfig globalConfig) {
        return new PtSqlExecutor(globalConfig);
    }

    public static SqlExecutor use(SqlExecutor.ExecutorType type, GlobalConfig globalConfig) {
        if (SqlExecutor.ExecutorType.JDBC.equals(type)) {
            return jdbc(globalConfig);
        } else if (SqlExecutor.ExecutorType.PT.equals(type)) {
            return pt(globalConfig);
        }
        throw new DapThrowException("不支持该执行器");
    }


}
